﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace Volunteer
{
    public partial class LoginPage : System.Web.UI.Page
    {
        private DBConn dbConn = new DBConn();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
                ViewState["LoginErrors"] = 0;
        }

        //protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
        //{
        //    if (dbConn.ValidateLogin(Login1.UserName, Login1.Password))
        //    {
        //        e.Authenticated = true;
        //        Login1.InstructionText = "Successfully Logged In";
        //    }
        //    else
        //    {
        //        e.Authenticated = false;
                
        //    }
        //}

        protected void Login1_LoginError(object sender, EventArgs e)
        {
            if (ViewState["LoginErrors"] == null)
                ViewState["LoginErrors"] = 0;

            int ErrorCount = (int)ViewState["LoginErrors"] + 1;
            ViewState["LoginErrors"] = ErrorCount;
            if ((ErrorCount > 3) && (Login1.PasswordRecoveryUrl != string.Empty))
                Response.Redirect(Login1.PasswordRecoveryUrl);
        }

        protected void Login1_LoggedIn(object sender, EventArgs e)
        {
            Globals.UserName = Login1.UserName;
        }

    }
}
